import QtQuick 2.0
import QtQuick.Controls 1.0
Rectangle{
    id:map
    property int column: 8
    property int row: 8
    property int cellsize: 80
    width: column*cellsize
    height: row*cellsize
    function indexText(index)
    {
        var _row=Math.floor(index/map.column)+1;
        var _cloumn=index%map.column+1;
        var text="("+_row+","+_cloumn+")";
        return text;
    }

    Grid{
        columns: map.column
        Repeater{
            model: mapValue.size()
            Rectangle{
                property bool flag: mapValue.value(index)
                color: flag == true?"black":"white"
                border.color: "blue"
                border.width: 2
                width: cellsize
                height: cellsize
                MouseArea{
                    anchors.fill: parent
                    onClicked: {
                        flag=!flag
                        mapValue.setValue(index,flag)
                    }
                }
                Text {
                    text: indexText(index)
                    font.pointSize: 16
                    anchors.centerIn: parent
                    color: flag == true?"white":"black"
                }
            }
        }
    }
}

